package com.vector.demo.controller.student;

import com.vector.demo.pojo.Assignment;
import com.vector.demo.pojo.Student;
import com.vector.demo.pojo.Task;
import com.vector.demo.service.AssignmentService;
import com.vector.demo.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import javax.websocket.server.PathParam;
import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentTaskController {

    @Autowired
    TaskService taskService;

    @Autowired
    AssignmentService assignmentService;

//    @RequestMapping("/queryAllTask")
//    public String queryAllTask(Model model) {
////        List<Task> tasks = taskService.queryAllTask();
////        Model taskList = model.addAttribute("taskList", tasks);
//        return "selectTask";
//    }

//    @ResponseBody
    @RequestMapping("/toNotSubmitList")
    public String toNotSubmitList(Model model, HttpSession session) {
        List<Task> tasks = taskService.queryAllTask();
        model.addAttribute("taskList", tasks);
        Student student = (Student) session.getAttribute("student");
        System.out.println(student);
        System.out.println(tasks);
//        return "1";
        return "student/not_submit";
    }

    @RequestMapping("/toSubmit")
    public String submit(int id, Model model) {
        Task task = taskService.queryTaskById(id);
        model.addAttribute("task",task);
        System.out.println(task);
        return "student/s_submit";
    }

    @RequestMapping("/toAlreadySubmit")
    public String toAlreadySubmit(Model model){
        List<Task> tasksList = taskService.queryAllTask();
        model.addAttribute("tasksList",tasksList);
        return "student/s_alreadySubmit";
    }

}
